package com.liu.activemq.spring;

import org.springframework.stereotype.Component;

import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

@Component
public class MyMessageListener implements MessageListener {

    public void onMessage(Message message) {
        if (message instanceof TextMessage) {
            TextMessage text = (TextMessage) message;
            try {
                System.out.println(text.getText());
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (message instanceof MapMessage) {
            MapMessage map = (MapMessage) message;
            System.out.println(map);
        } else {
            System.out.println("未识别的类型");
        }
    }
}
